package com.ynet.eq.aop.comfig;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author 胡超雄
 * @date 2021/7/16 15:07
 * @desc
 */
@Aspect
@Component
@Slf4j
@Order(2)
public class Aspect2 {
    @Pointcut("@annotation(com.ynet.eq.aop.comfig.AopDemo)")
    private void cutMethod() {

    }

    /**
     * 环绕通知
     *
     * @param point
     * @return Object
     * @throws Throwable
     */
    @Around("cutMethod()")
    public Object around(ProceedingJoinPoint point) throws Throwable {

        System.out.println("第二个执行开始了");
        // 执行方法
        Object result = point.proceed();
        // 执行时长(毫秒)
        System.out.println("第二个执行结束了了");
        return result;
    }
}
